package practice;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;

public class _Z字型层序遍历_ {
//    private TreeNode ;

    public static void main(String[] args){
        List<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(2);
        list.add(3);
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i) );
        }
        list.add(list.size()-1,5);

        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }

        _Z字型层序遍历_ c = new _Z字型层序遍历_();
        _Z字型层序遍历_.Solution s = c.getSolution();

        TreeNode n1 = new TreeNode(8);
        TreeNode n2 = new TreeNode(6);
        TreeNode n3 = new TreeNode(10);
        TreeNode n4 = new TreeNode(5);
        TreeNode n5 = new TreeNode(7);
        TreeNode n6 = new TreeNode(9);
        TreeNode n7 = new TreeNode(11);
        n1.left = n2;
        n1.right = n3;
        n2.left = n4;
        n2.right = n5;
        n3.left = n6;
        n3.right = n7;
        List<TreeNode> res = s.zBFS(n1,0);
        System.out.println("finish...");
    }

    Solution getSolution() {
        return new Solution();
    }

    class Solution {
        public List<TreeNode> zBFS(TreeNode root,int level ) {
            List<TreeNode> res = new ArrayList<TreeNode>();
            Queue<TreeNode> que = new LinkedList<TreeNode>();
            if (root == null) return null;
            else que.add(root);
            if (level > que.size()){
                que.add(root);
            }
            return res;
        }
    }

}
